package cn.paidaxin.listener;

import cn.paidaxin.domain.dto.ClockInDTO;
import cn.paidaxin.service.ClockinCoreOpService;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 内网存在断网问题,消息消费不到 暂时弃用
 *
 * @author Pai dx
 * @Description 外部 MQ 推送打卡
 * @date 2021-10-18 11:41
 **/
@Slf4j
@Component
@RabbitListener(queues = "clock_in_queue")
public class XinnuoClockListener {

    @Autowired
    private ClockinCoreOpService clockinCoreOpService;

    @RabbitHandler
    public void xinnuoClockListener(String msg) throws Exception {
        ClockInDTO msgInfo = JSONObject.parseObject(msg, ClockInDTO.class);
        log.info("打卡消息接受- start ， 打卡类别：{},{}", msgInfo.getClockType(), msg);
        boolean b = clockinCoreOpService.clockinCoreOp(msgInfo);

        log.info("打卡状态：{}", b);
    }
}
